import requests
from lxml import etree
from multiprocessing.dummy import Pool    # 进行多线程操作

# 太难了。。。

headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'
}
url = 'https://www.pearvideo.com/category_4'
session = requests.Session()
responce = session.get(url=url, headers=headers)
html = responce.text
# with open('lishiping.html','w',encoding='utf-8') as fp:
#     fp.write(html)
tree = etree.HTML(html)
url_list = tree.xpath('//*[@id="listvideoListUl"]/li/div/a/@href')
print(url_list)
responce = session.get(url='https://www.pearvideo.com/'+url_list[0], headers=headers)
html = responce.text
with open('lishiping.html','w',encoding='utf-8') as fp:
    fp.write(html)
# videos = []
# for li in li_list:
#     name = li.xpath('./div/a/div[2]/text()')
#     url = li.xpath('')

# pool = Pool(4)    # 创建4个线程
# pool.map(......)
